<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>

<%@ page import="Database.Document" %>
<%@ page import="Database.DocumentVector" %>
<%@ page import="InformationRetriever.Formulas" %>

<%@ include file="/header" %>

<%
    DocumentVector list = null;
    int i = 0;
    
    try
    {
        list = (DocumentVector)request.getAttribute("list");
    }
    catch(Exception e)
    {
        ///if the file list is null, redirect to the proper  page...
        response.sendRedirect(siteRoot+"/Compare");
    }
    
    if(list == null)
    {
        response.sendRedirect(siteRoot+"/Compare");
    }
%>
    
    <div id="compareForm">
        <p>Select two documents to perform a compare.</p>
        <form action="<%=siteRoot%>/Compare" method="get">
            <p>
                <select name="doc1" alt="Documento 1" title="Document 1" size="15">
                    <%
                    i = 0;
                    for(Document doc : list)
                    {
                    %>
                    <option value="<%=i++%>" /><%=i%>. <%=doc.toString()%>
                    <%
                    }
                    %>
                </select>
                <select name="doc2" alt="Documento 2" title="Document 2" size="15">
                    <%
                    i = 0;
                    for(Document doc : list)
                    {
                    %>
                    <option value="<%=i++%>" /><%=i%>. <%=doc.toString()%>
                    <%
                    }
                    %>
                </select>
            </p>
            <p>
                <select name="formula" alt="Select a formula" title="Select a formula">
                    <option value="<%=Formulas.InnerProduct%>" /><%=Formulas.InnerProduct.title()%>
                    <option value="<%=Formulas.Cosine%>" /><%=Formulas.Cosine.title()%>
                    <option value="<%=Formulas.DiceCoefficient%>" /><%=Formulas.DiceCoefficient.title()%>
                    <option value="<%=Formulas.JaccardCoefficient%>" /><%=Formulas.JaccardCoefficient.title()%>
                    <option value="<%=Formulas.EuclideanDistance%>" /><%=Formulas.EuclideanDistance.title()%>
                    <option value="<%=Formulas.ManhattanDistance%>" /><%=Formulas.ManhattanDistance.title()%>
                </select>
                <input type="image" id="compareSubmitIcon" src="<%=siteRoot%>/compare/compare.png" alt="Compare documents" title="Compare documents" />
            </p>
        </form>
        <p>Or <a href="<%=siteRoot%>/Query">perform a query over the indexed document base</a>.</p>
    </div>
    
<%@ include file="/footer" %>
